﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
using DAL;
using System.Data;

namespace BLL
{
    public class AGVInfoManager
    {
        private AGVInfoService objAGVInfoService = new AGVInfoService();
        /// <summary>
        /// 获取AGV基本信息
        /// </summary>
        /// <returns></returns>
        public List<AGVInfo> GetAGVInfo(string agvStatus)
        {
            return objAGVInfoService.GetAGVInfo(agvStatus);
        }
        /// <summary>
        /// 新增AGV信息
        /// </summary>
        /// <param name="objAGVInfo"></param>
        /// <returns></returns>
        public int AddAGVInfo(AGVInfo objAGVInfo)
        {
            if (objAGVInfoService.IsExistsAGVByIP(objAGVInfo.IP) != 0)
            {
                throw new Exception("该IP的AGV已经存在，添加失败");
            }
            return objAGVInfoService.AddAGVInfo(objAGVInfo);
        }
         /// <summary>
        /// 修改AGV信息
        /// </summary>
        /// <param name="objAGVInfo"></param>
        /// <returns></returns>
        public int ModifyAGVInfo(AGVInfo objAGVInfo)
        {
            return objAGVInfoService.ModifyAGVInfo(objAGVInfo);
        }
        // <summary>
        /// 按AGVID号删除信息
        /// </summary>
        /// <param name="agvId"></param>
        /// <returns></returns>
        public int DeleteAGVInfo(string agvId)
        {
            return objAGVInfoService.DeleteAGVInfo(agvId);
        }
        /// <summary>
        /// 添加Agv信息
        /// </summary>
        /// <param name="aVGINFO"></param>
        /// <returns></returns>
        public int AddAGVMessage(AGV aVGINFO)
        {
            return objAGVInfoService.AddAGVMessage(aVGINFO);
        }
        /// <summary>
        /// 查询id
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public string GetAGVId(string ip)
        {
            return objAGVInfoService.GetAGvid(ip);
        }
        /// <summary>
        /// 查询id
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public string GetAGVName(string ip)
        {
            return objAGVInfoService.GetAGvName(ip);
        }
        /// <summary>
        /// 获取所有ip
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public DataTable GetAGVip()
        {
            var ipdata = objAGVInfoService.GetAgvip();
            if (ipdata.Tables[0].Rows.Count > 0)
            {
                return ipdata.Tables[0];
            }

            return null;

        }
    }
}
